from multiprocessing import Process, Pool
import os


def info(title):
    print(title)
    print('module name:', __name__)
    print('parent process:', os.getppid())
    print('process id:', os.getpid())


def f(name):
    info('function f')
    print('hello', name)


def f2(x):
    return x * x


if __name__ == '__main__':
    with Pool(2) as p:
        # print(p.map(f2, range(20)))
        # for item in p.map(f2,range(20)):
        #     print(item)
        # print same numbers in arbitrary order
        for i in p.imap_unordered(f2, range(10)):
            print(i)
